<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     * 用户
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_general_ci';
            $table->increments('id');
            $table->string('name',50)->comment('用户名');
            $table->string('real_name',50)->comment('真实姓名');

//            $table->string('email',50)->unique();
            // $table->string('phone',11)->unique()->comment('绑定手机号');
            //取消约束
            $table->string('email',50)->default('')->comment('邮箱');
            $table->string('phone',11)->default('')->comment('绑定手机号');
            $table->string('address',128)->comment('地址')->nullable();
            $table->string('receiver',50)->comment('收货人')->nullable();
            $table->string('password',255)->default('');
            $table->decimal('credit',10,2)->comment('贡献值')->nullable();
            $table->decimal('reward',10,2)->comment('安全币')->nullable();
            $table->tinyInteger('status')->default(1);

            $table->tinyInteger('source')->default(1)->comment('来源，1内部用户');
            $table->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP'));
            $table->timestamp('updated_at')->nullable();
            $table->timestamp('deleted_at')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
